package com.he.DesignPatterns.factory.SimpleFactory;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/8/26 9:42
 */
public class CoffeeFactory {

//    public Coffee createCoffee(String type) {
//        Coffee coffee = null;
//        if ("A".equalsIgnoreCase(type)) {
//            coffee = new AmericanCoffee();
//        } else if ("B".equalsIgnoreCase(type)) {
//            coffee = new LatteCoffee();
//        } else {
//            throw new RuntimeException("没有该咖啡");
//        }
//        return coffee;
//    }

    public static Coffee createCoffee(String type) {
        Coffee coffee = null;
        if ("A".equalsIgnoreCase(type)) {
            coffee = new AmericanCoffee();
        } else if ("B".equalsIgnoreCase(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("没有该咖啡");
        }
        return coffee;
    }
}
